#!/usr/bin/env expect

set user "admin"
set passwd ""
set su_passwd ""
set timeout 10

# 工控机ip
set ip [lindex $argv 0 ]

spawn ssh -l $user $ip
expect {
	"(yes/no)?" {
		send "yes\n"
		expect "password:"
		send "$passwd\n"
	}
	"password:" {
		send "$passwd\n"
	}
}

# 切换root
expect ">"
send "sftp enable\n"
expect ">"
send "develop\n"
expect "Password: "
send "$su_passwd\n"

# 防自动退出
expect "#"
send "export TMOUT=100000\n"

# 启用2G内存
#expect "#"
#send "fw_setenv bootargs_a\n"
#expect "#"
#send "fw_setenv bootargs_b\n"
#expect "#"
#send "reboot\n"

# 停留交互界面
interact

# 退出
#expect "#"
#send "exit\n"
#expect ">"
#send "exit\n"

#expect eof

